package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.CompanyMapper;
import com.ruoyi.system.domain.Company;
import com.ruoyi.system.service.ICompanyService;

/**
 * 小区管理Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-04-02
 */
@Service
public class CompanyServiceImpl implements ICompanyService 
{
    @Autowired
    private CompanyMapper companyMapper;

    /**
     * 查询小区管理
     * 
     * @param companyId 小区管理ID
     * @return 小区管理
     */
    @Override
    public Company selectCompanyById(Long companyId)
    {
        Company company = companyMapper.selectCompanyById(companyId);
        company.setCompanyDeptName(companyMapper.queryDeptByid(company.getCompanyDept()));
        return company;

    }

    /**
     * 查询小区管理列表
     * 
     * @param company 小区管理
     * @return 小区管理
     */
    @Override
    public List<Company> selectCompanyList(Company company)
    {
        List<Company> companies = companyMapper.selectCompanyList(company);
        for (int i = 0; i <companies.size() ; i++) {
            companies.get(i).setCompanyDeptName(companyMapper.queryDeptByid(companies.get(i).getCompanyDept()));
        }
        return companies;
    }

    /**
     * 新增小区管理
     * 
     * @param company 小区管理
     * @return 结果
     */
    @Override
    public int insertCompany(Company company)
    {company.setCreateTime(DateUtils.getNowDate());
        return companyMapper.insertCompany(company);
    }

    /**
     * 修改小区管理
     * 
     * @param company 小区管理
     * @return 结果
     */
    @Override
    public int updateCompany(Company company)
    {
        return companyMapper.updateCompany(company);
    }

    /**
     * 批量删除小区管理
     * 
     * @param companyIds 需要删除的小区管理ID
     * @return 结果
     */
    @Override
    public int deleteCompanyByIds(Long[] companyIds)
    {
        return companyMapper.deleteCompanyByIds(companyIds);
    }

    /**
     * 删除小区管理信息
     * 
     * @param companyId 小区管理ID
     * @return 结果
     */
    @Override
    public int deleteCompanyById(Long companyId)
    {
        return companyMapper.deleteCompanyById(companyId);
    }
}
